In this project I've been focused on simple physics and graphics programming. Asteroids gave me an opporunity to dive a bit deeper into shaders development since I've decided to not use any predefined SFML shapes.
Very simple architecture with a simple base object class used for all game objects (player ship, asteroids, projectiles). There are only 3 application states: main menu, gameplay and end game screen.
SFML library has been used to help in windows creation as well as text elements and easy glsl shaders binding.
I wanted to take this opportunity to explore and learn a bit more about writing custom shaders to do some effects that are not easly achievable with basic geometry shapes provided by the library.
All gameplay objecs (player ship, asteroids, projectiles) are rendered with the help of vertex, geometry and fragment shaders.
Basically all objects are rendered as simple connected lines.
Player ship geometry has been handcrafted in code to get this specific, arrow-like shape.
Unlike Player Ship, the Asteroids shapes have been generated randomly as deformated spheres.
When hit, a bigger Asteroid can be broken into multiple smaller ones.
Destruction animation has been implemented by just slow reduction in distance between the lines vertices.
If the object's geometry is offscreen, it's going to appear on the other side of the display. Visually this effect has been achieved by writing a custom geometry shader which wraps the coordinates of each vertex depending on its position.
Player has to destroy as many asteroids he can before he gets destroyed. There are 3 lives in each game after losing which the game is over and the screen with player score is shown.
Player ship is controller via arrow keys and projectiles can be fired by hitting the spacebar.
Asteroids derive from the the base game object class and can move with various speeds in random direction.
Very simple HUD bult from scratch consisting mostly from SFML text elements.